<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>

<%@ page import="manage.BugManage"%>

<%@ page import="java.util.ArrayList"%>
<%@ page  import="object.Module"%>
<%@ page import="java.util.ArrayList"%>
<%@page import="object.Bug"%>
<%@page import="manage.ProjectManage"%>
<%@page import="manage.UserManage"%>
<%@page import="manage.ModuleManage"%>
<jsp:useBean id="procedure" scope="page" class="Procedure.UseProcedure"/>  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<% 
   String ID=request.getParameter("BugID");
   if(ID!=null)
   {int BugID=Integer.parseInt(ID);
    Bug bug=BugManage.getBug(BugID);
    
  
 %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>编辑bug</title>
<link href="css/foreground.css" rel="stylesheet" type="text/css" />
<link rel="StyleSheet" href="css/dtree.css" type="text/css" />
<script type="text/javascript" src="JS/for_dtree.js"></script>
<script> 
function go(obj){ 
self.location=obj.options[obj.selectedIndex].value; 
return false; 
} 

</script> 
</head>
 
 <BODY id=css-zen-garden>
 <script language="JavaScript"> 
<!--
  var subcat = new Array(); 
  var usercat= new Array(); 
<%
  int h=0;
  int puser=0;
  String userid1=(String)session.getAttribute("UserID");
 if(userid1!=null)
 {
  int UserID1=Integer.parseInt(userid1);
  ResultSet rs1=procedure.getProjectLists(UserID1);

  while(rs1.next())
  {
    
   int project1=rs1.getInt("ProjectID");
   ArrayList list=procedure.getModules(project1);
   ResultSet rs2=procedure.getUsers(project1);
   for(int count=0;count<list.size();count++)
   {
    Module module=(Module)list.get(count);
    String modulename=module.getModuleName();
    int moduleid=module.getModuleID();
  %>
    subcat[<%= h%>]=new Array('<%= project1%>','<%= modulename%>','<%= moduleid%>')
    
  <%
    h++;
   }
    
   while(rs2.next()) 
    {
     String username=rs2.getString("UserName");
     int userid=rs2.getInt("UserID");
 %>
    usercat[<%= puser%>]= new Array('<%= project1%>','<%= username%>','<%= userid%>')    
  <%
   
     puser++;  
    }
    rs2.close();
 }
 
  rs1.close();
  

 
 
 }

%>
function changeselect1(locationid)   
{   //document.EditBugForm.User.length=0;
    
     document.EditBugForm.module.length = 0;   
      //document.EditBugForm.MailTo.length=0;
      document.EditBugForm.OpenedBy.length=0;
      document.EditBugForm.BugType.length=0;
      document.EditBugForm.ResolvedBy.length=0;
      document.EditBugForm.ClosedBy.length=0;
      document.EditBugForm.module.options[0] = new Option('==选择模块==','0');   
      document.EditBugForm.ClosedBy.options[0] = new Option('','0');
      document.EditBugForm.ResolvedBy.options[0]=new Option('','0');
    for (i=0; i<subcat.length; i++)   
    {   
        if (subcat[i][0] == locationid)   
        {document.EditBugForm.module.options[document.EditBugForm.module.length] = new Option(subcat[i][1], subcat[i][2]);}   
    }  
    
   
    for(i=0;i<usercat.length;i++)
    {
     if (usercat[i][0] == locationid)   
        {  document.EditBugForm.OpenedBy.options[document.EditBugForm.OpenedBy.length] = new Option(usercat[i][1], usercat[i][2]);
         //document.EditBugForm.MailTo.options[document.EditBugForm.MailTo.length] = new Option(usercat[i][1], usercat[i][2]);
           document.EditBugForm.ResolvedBy.options[document.EditBugForm.ResolvedBy.length]=new Option(usercat[i][1], usercat[i][2]);
           document.EditBugForm.ClosedBy.options[document.EditBugForm.ClosedBy.length]=new Option(usercat[i][1], usercat[i][2]);
        }   
    
    }
    
    document.EditBugForm.BugType.options[0]=new Option("资源泄露",'1'); 
    document.EditBugForm.BugType.options[1]=new Option("内存溢出",'2'); 
    document.EditBugForm.BugType.options[2]=new Option("同步问题",'3');  
    document.EditBugForm.BugType.options[3]=new Option("进程间通信问题",'4'); 
    document.EditBugForm.BugType.options[4]=new Option("逻辑错误",'5'); 
    document.EditBugForm.BugType.options[5]=new Option("莫名其妙的崩溃",'6'); 
    document.EditBugForm.BugType.options[6]=new Option("其他",'7'); 
   
    
    
    
}  

</script>
 
<DIV id=container>
<DIV id=intro>
<DIV id=quickSummary>
 <p class=p2>欢迎，<%=session.getAttribute("RealName") %>;<a href="login.jsp">退出</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="EditUser.jsp">修改资料</a>&nbsp;&nbsp;
    <%
     String level= null;
     level=(String)session.getAttribute("UserLevel");
     if(level!=null&&level.equals("0"))
     {
     %> 
      <a href="admin/AddGroup.jsp">进入后台</a>
      <%
       }
       %></p>
</DIV>
<DIV id=buginfo>
<H3><SPAN>编辑BUG</SPAN></H3>
  <form id="EditBugForm" name="EditBugForm" method="post" enctype="multipart/form-data"  action="editBug">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td colspan="4" align="center">项目：模块</td>
        </tr>
      <tr>
        <td colspan="4" align="center" ><table width="100%" border="0" cellpadding="0" cellspacing="1" class="table_style">
  <tr bgcolor="#52514E">
    <td colspan="6">编辑BUG</td>
  </tr>
   <tr bgcolor="#52514E">
    <td>Bug编号</td>
    <td align="left"> 
  <input type="text" name="BugID" id="BugID" readonly="readonly" value="<%=bug.getBugID()  %>" ;/>
    
    </td></tr> 
  <tr bgcolor="#52514E">
    <td>项目和模块</td>
    <td align="left">
        <select name="project" id="project" onclick="changeselect1(this.value)"  >
         <%   
                int pid=bug.getProjectID();
                String pname=ProjectManage.GetProjectMess(pid).getProjectName();
	            String puserid=(String)session.getAttribute("UserID");
	            if(puserid!=null)
	            {  int UserID=Integer.parseInt(puserid);
	               ResultSet rs=procedure.getProjectLists(UserID);
	               while(rs.next())
	               {
	                 String ProjectName=rs.getString("ProjectName");
	                 int ProjectID=rs.getInt("ProjectID");
	                 if(ProjectName.equals(pname))
	                 {%>
	                 <option value="<%= ProjectID%>" selected="selected" ><%=ProjectName %></option>
	                 
	                 <% 
	                  
	                 }
	                 else
	                 {
	         %> 
	        <option value="<%= ProjectID%>"><%=ProjectName %></option>
	          <% 
	           }  
	             }
	                rs.close();
            }
          %>
        </select>
        <%
         String moduleName=ModuleManage.GetModuleMess(bug.getModuleID()).getModuleName(); 
        %>
        <select name="module" id="module">
        <option value="<%=bug.getModuleID() %>"><%= moduleName %></option>
        </select></td>
  </tr>
  <tr bgcolor="#52514E">
    <td>Bug标题</td>
    <td align="left"><input type="text" name="BugTitle" id="BugTitle"  value="<%=bug.getBugTitle()  %>" ;/></td></tr></table></td>
        </tr>
          <tr>
        <td colspan="2" align="center" width="50">Bug状态</td>
        <td colspan="2" align="center">创建</td>
        </tr>
      <tr>
      <tr>
        <td>&nbsp;类型</td>
        <td >
        <select name="BugType" id="BugType">
        <option selected="selected" value="<%= bug.getBugTypeID() %>";><%= bug.getBugType() %></option>
        </select>
       </td>
        <td>由谁创建</td>
        <td><select name="OpenedBy" id="OpenedBy">
        <%int uid=bug.getOpenedByID();
          String uname=UserManage.GetUserName(uid).getUserName(); %>
        <option selected="selected"  value="<%= uid %>"><%= uname %></option>
        <option>&nbsp;</option>
        </select></td>
      </tr>
      
      <tr>
        <td>&nbsp;严重程度</td>
        <td><select name="BugSeverity" id="BugSeverity">
        <option selected="selected" value="1" >1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        </select></td>
        <td>创建Build</td>
        <td> <input type="text" name="OpenedBuild" id="OpenedBuild"  value="<%= bug.getOpenedBuild() %>"/></td>
      </tr>
      <tr>
        <td>&nbsp;状态</td>
        <td><select name="BugStatus" id="BugStatus">
        <option selected="selected" value="1">Active</option>
        <option  value="2">Resolved</option>
        <option  value="3">Closed</option>
        </select></td>
        <td colspan="2" align="center">解决</td>
        </tr>
      <tr>
        <td>&nbsp;指派给</td>
        <td>
       
      <input type="text" name="AssignedUsers" id="AssignedUsers"  value="<%= bug.getAssignedToName() %>"/>
        </td>
        <td>由谁解决</td>
        <td><select name="ResolvedBy" id="ResolvedBy">
        <option selected="selected" value="<%= bug.getResolvedByID() %>"><%= bug.getResolvedByName() %></option>
        
        </select></td>
      </tr>
      <tr>
        <td>&nbsp;发信通知</td>
        <td><input type="text" name="MailTos" id="MailTos" value="<%= bug.getMailTo() %>" /></td>
        <td>解决日期</td>
        <%if(bug.getResolvedDate()==null) 
          {
        %>
        <td><input type="text" name="ResolvedDate" id="ResolvedDate"  /></td>
        <%
          }
          else
          {
         %>
        <td><input type="text" name="ResolvedDate" id="ResolvedDate" value="<%= bug.getResolvedDate() %>" /></td>
         <%
          }
          %>
      </tr>
      <tr>
        <td>&nbsp;相关Bug</td>
        <td><input type="text" name="LinkID" id="LinkID" value="<%= bug.getLinkID()  %>"; /></td>
        <td>解决Build</td>
        <td><input type="text" name="ResolvedBuild" id="ResolvedBuild" value="<%= bug.getResolvedBuild() %>" /></td>
      </tr>
      <tr>
        <td colspan="2" align="center">描述</td>
        <td>解决方案</td>
        <td><select name="Resolution" id="Resolution">
         <option value="0"></option>
        <option  value="1">By Design</option>
        <option value="2">Duplicate</option>
        <option value="3">Not Repro</option>
        <option value="4">Fixed</option>
        <option value="5">External</option>
        <option value="6">Postponed</option>
        <option value="7">Won't Fix</option>
        </select></td>
      </tr>
      <tr>
        <td rowspan="3">&nbsp;描述</td>
        <td rowspan="3"><textarea name="ActionNote" id="ActionNote" cols="25" rows="5">  </textarea> </td>
        <td colspan="2" align="center">关闭</td>
        </tr>
      <tr>
        <td>由谁关闭</td>
        <td><select name="ClosedBy" id="ClosedBy">
        <option selected="selected" value="<%= bug.getClosedByID() %>"><%= bug.getClosedByName() %></option>
       
        </select></td>
      </tr>
      <tr>
        <td>关闭日期</td>
        <%
         if(bug.getClosedDate()==null)
         {
         %>
          <td><input type="text" name="ClosedDate" id="CloseDate" /></td>
          <%
         }
         else
         {
           %>
        <td><input type="text" name="ClosedDate" id="CloseDate" value="<%= bug.getClosedDate() %>" /></td>
       <%
         }
        %>
      </tr>
    
      <tr>
        <td colspan="4" align="center">添加附件</td>
        </tr>
      <tr>
        <td>&nbsp;选择文件</td>
        <td align="left"><input name="filename" type="file" id="filename" size="25" maxlength="200" dataType="Require" msg="选择上传文件" />
    
    </td>
     <td>新文件名</td>
     <td  align="left" ><input name="title" type="text" id="title" size="28" maxlength="28"  dataType="Require" msg="输入题目" /></td>
      </tr>
          <tr>
    <td colspan="6" align="center" height="30px"><input  type="submit" value="更新" /></td>
    
  </tr>
  
  
    </table>
<%
  }
 %>
      </form> 
     
</DIV></DIV>
<DIV id=supportingText></DIV>
<DIV id=linkList>
<DIV id=linkList2>
<DIV id=lselect>
<H3 class=select></H3>
<UL>
   <li><a href="QueryBug.jsp?QueryMode=Whole"><span 
  class=accesskey>查看BUG</span></a> </li>
          <li><a href="AddBug.jsp"><span 
  class=accesskey>创建BUG</span></a> </li>
  </UL>
</DIV>
<DIV id=larchives>
<H3 class=archives><SPAN></SPAN></H3>
<UL>
        <LI>
        <form id="form1" name="form1" method="post" action="">
        <select name="ProductList" class="treelist" id="ProcuctList" onchange="go(this)" >
           <option value="0">维护项目</option>
          <%  
             String userID=(String)session.getAttribute("UserID");
           if (userID!=null)
             {
             int projectID=0;
            if(request.getParameter("projectID")!=null)
            { 
             projectID=Integer.parseInt(request.getParameter("projectID"));
            }
             int UserID=Integer.parseInt(userID);
             ResultSet rs=procedure.getProjectLists(UserID);
            while(rs.next())
          { String ProjectName=rs.getString("ProjectName");
            int ProjectID=rs.getInt("ProjectID");
            if(ProjectID==projectID)
            {
            %>
             <option  value="EditBug.jsp?projectID=<%= ProjectID%>&BugID=<%= request.getParameter("BugID") %>"    selected="selected"><%=ProjectName %></option>
            <% 
            }
           else
            {
           %> 
            <option value="EditBug.jsp?projectID=<%= ProjectID%>&BugID=<%= request.getParameter("BugID") %>" ><%=ProjectName %></option>
          <% 
            }
            }
            rs.close();
            }
          %>
          </select>
        </form> 
      </LI>
           <li>
        

     
     
     
      
</UL></DIV>
<DIV id=lresources>
<H3 class=resources></H3>
<UL>
    <li><a href="QueryBug.jsp?QueryMode=AssignedTo"><span class=accesskey>指派给我的BUG</span></a> </li>
    <li><a href="QueryBug.jsp?QueryMode=Opened"><span class=accesskey>由我创建的BUG</span></a> </li>
  </UL>
</DIV></DIV></DIV></DIV></BODY>
</html>
 